//
//  ZDGlobalConfig.h
//  ZHIDOU
//
//  Created by 向礼 on 2018/12/18.
//  Copyright © 2018 向礼. All rights reserved.
//

#ifndef ZDGlobalConfig_h
#define ZDGlobalConfig_h

/***
 1、适配相关宏定义
 */

/** 状态栏高度   */
#define ZD_statusBarHeight  [[UIApplication sharedApplication] statusBarFrame].size.height

/** 安全区域    */
#define ZD_safeAreaInsets_top [UIApplication sharedApplication].delegate.window.safeAreaInsets.top
#define ZD_safeAreaInsets_bottom [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom
#define ZD_safeAreaInsets_left [UIApplication sharedApplication].delegate.window.safeAreaInsets.left
#define ZD_safeAreaInsets_right [UIApplication sharedApplication].delegate.window.safeAreaInsets.right

/** 宽高  */
#define ZD_screenWidth [UIScreen mainScreen].bounds.size.width
#define ZD_screenHeight [UIScreen mainScreen].bounds.size.height
#define ZD_defaultScale [UIScreen mainScreen].bounds.size.width / 375.0
#define isIPhoneX ZD_screenHeight==812
#define bottomMargin (isIPhoneX ? 34 : 0)
#define kScrollViewBeginTopInset 240

/** 设备是否为iPhone 4/4S 分辨率320x480，像素640x960，@2x */
#define ZD_iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

/** 设备是否为iPhone 5C/5/5S 分辨率320x568，像素640x1136，@2x */
#define ZD_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

/** 设备是否为iPhone 6 分辨率375x667，像素750x1334，@2x */
#define ZD_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

/** 设备是否为iPhone 6 Plus 分辨率414x736，像素1242x2208，@3x */
#define ZD_iPhone6P ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

/** 设备是否为iPhone X 分辨率375x812，像素1125 * 2436 ，@3x */
#define ZD_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define DT_IS_IPHONEX_XS (ZD_screenHeight == 812.f)//是否是iPhoneX、iPhoneXS

#define DT_IS_IPHONEXR_XSMax (ZD_screenHeight == 896.f)//是否是iPhoneXR、iPhoneX Max

#define IS_IPHONEX_SET (DT_IS_IPHONEX_XS||DT_IS_IPHONEXR_XSMax)//是否是iPhoneX系列手机

/** 判断是不是手机 */
#define ZD_IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define ZD_IS_IPHONE_6PLUS (IS_IPHONE && [[UIScreen mainScreen] scale] == 3.0f)

// 需要修改的地方********************待改正
#define ZD_screenHeight_IPHONE_6_6S 667
#define ZD_screenHeight_IPHONE_PLUS 736

/** 适配以6的设计稿 */
#define ZD_screenHeight_IPHONE_6 667
#define ZD_screenWidth_IPHONE_6 375

/***
 2、字符串相关宏定义
 */

/** 字符串是否为空 */
#define ZD_StringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || [str isEqualToString:@"<null>"] || [str isEqualToString:@"(null)"]|| str == nil || [str length] < 1 ? YES :NO)

/** 数组是否为空  */
#define ZD_ArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)

/** 字典是否为空  */
#define ZD_DictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.count == 0)

/// 解决循环引用，用__weak 来修饰
#define ZD_weakSelf __weak typeof(self) weakSelf = self;


#endif /* ZDGlobalConfig_h */
